package cn.ad.server.job.adapter.persistence.job;

import java.util.List;

import javax.annotation.Resource;

import cn.ad.server.job.domain.job.AreaPlatformMapRepositoryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;

import cn.ad.server.persistence.dao.AreaPlatformMapDao;
import cn.ad.server.domain.ad.AreaPlatformMap;

@Repository
public class AreaPlatformMapRepositoryServant implements AreaPlatformMapRepositoryService {

	static final Logger logger = LoggerFactory.getLogger(AreaPlatformMapRepositoryServant.class);

	@Autowired
	private AreaPlatformMapDao areaPlatformMapDao;

	@Resource(name = "cacheRedisTemplate")
	private ValueOperations<String, AreaPlatformMap> areaValueOperations;
	
	@Override
	public void warmAllAreaPlatformMap() {
		List<AreaPlatformMap> areaPlatformMaps = areaPlatformMapDao.findAll();
		
		for (AreaPlatformMap areaPlatformMap : areaPlatformMaps) {
//			AreaPlatformMap areaPlatformMap2 = areaValueOperations.get(areaPlatformMap.toCacheKey());
//			System.out.println(areaPlatformMap2);
			areaValueOperations.set(areaPlatformMap.toCacheKey(), areaPlatformMap);
		}
		
	}
}
